<?php
class TwoStacksQueue
{
    public $stackPush = [];
    public $stackPop = [];

    public function add($value)
    {
        array_push($this->stackPush,$value);
    }

    public function poll()
    {
        if( empty($this->stackPush) && empty($this->stackPop)) {
            throw new Exception('Queue is Empty');
        } else if(empty($this->stackPop)){
            while (!empty($this->stackPush)) {
                array_push($this->stackPop,array_pop($this->stackPush));
            }
        }
        return array_pop($this->stackPop);
    }

    public function peek()
    {
        if(empty($this->stackPop) && empty($this->stackPush)) {
            throw new Exception("Queue is Empty");
        } else if (empty($this->stackPop)) {
            while (!empty($this->stackPush)) {
                array_push($this->stackPop,array_pop($this->stackPop));
            }
        }
        return $this->peek();
    }
}